package mysql

import (
	"database/sql"
	"fmt"
)

// 删除数据超过一定时间的数据
func DeleteByTime(db *sql.DB, ip string) bool {

	//设置参数以及执行sql语句
	insetStr := `delete From %s where DATE(time) <= DATE(DATE_SUB(NOW(),INTERVAL 1 day))`
	insetStr = fmt.Sprintf(insetStr, ip)
	var _, execErr = db.Exec(insetStr)
	if execErr != nil {
		fmt.Println(execErr)
		return false
	}
	return true

}
